package cn.itsource.zcn.order.controller;

import cn.itsource.zcn.order.domain.OrderAdopt;
import cn.itsource.zcn.order.service.IOrderAdoptService;
import cn.itsource.zcn.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;


/**
 * (OrderAdopt)表控制层
 *
 * @author makejava
 * @since 2021-08-26 11:07:38
 */
@RestController
@RequestMapping("/order")
public class OrderAdoptController {
    /**
     * 服务对象
     */
    @Autowired
    private IOrderAdoptService tOrderAdoptService;

    /**
     * 查询全部数据
     *
     * @return List<>
     */
    @RequestMapping("/all")
    public List<OrderAdopt> queryAll() {
        return tOrderAdoptService.queryAll();
    }

    @PostMapping("/submitOrder")
    public AjaxResult submitOrder(@RequestBody Map<String,String> map, HttpServletRequest request){
        try {
            String result = tOrderAdoptService.submitOrder(map, request);
            return AjaxResult.me().setResultObj(result);
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult("订单失败");
        }
    }
}
